// xc_lshop/shop/deposit/take/com/checkpros.js
var actdepositbill = require('../../../model/deposit_bill')

Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    operator: String,
    order: Object,
  },

  /**
   * 组件的初始数据
   */
  data: {
    show: false,
    modellist: [],
    form: {}
  },

  /**
   * 组件的方法列表
   */
  methods: {
    oncomfirm() {
      var that = this;
      var model = {
        modellist: this.data.modellist,
        form: this.data.form
      }
      if (this.data.depositid) {
        model['depositid'] = this.data.order.id
      }

      console.log("model")
      console.log(model)

      actdepositbill.createoutorder(model).then(function (res) {
        if (res["status"] == 1) {
          if (that.data.operator == 'user') {
            var obj = res["obj"]
            that.selectComponent("#qrcode").init(2, obj)
          } else {
            wx.showModal({
              title:"取件成功",
              content:"取件成功,是否重新扫码？",
              confirmText: '重新扫码',
              cancelText:'返回首页',
              success (res) {
                if (res.confirm) {
                  wx.scanCode({
                    success (res) {
                      console.log(res)
                    }
                  })
                
                } else if (res.cancel) {
                  wx.redirectTo({
                    url: '/xc_lshop/index/index',
                  })
                }
              }
            })
          }
        } else {
          wx.showModal({
            title: '错误',
            content: res["message"],
          })
        }
      })
    },
    init(list, form) {
      this.setData({
        modellist: list,
        form: form,
        show: true
      });

    },
    onClose() {
      this.setData({
        show: false
      });
    },
  }
})